<template>
  <div class="owner">
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span style="line-height: 36px;">货主管理</span>
        <el-button style="float: right;" type="primary" @click="dialogOpen()" v-if="USER.auth.indexOf('business_owner_add')!==-1">新增货主</el-button>
      </div>
      <s-table
        :table="table"
        @http="tableWatch">
        <el-table-column
          fixed="right"
          align="center"
          slot="operation"
          class-name="operationMore"
          label="可用操作"
          width="80">
          <template scope="s">
            <el-button type="info" icon="search" size="mini" @click="dialogLibraryOpen(s.row)" v-if="USER.auth.indexOf('business_owner_edit_kuwei')!==-1"></el-button>
            <el-tooltip placement="top">
              <div slot="content">更多可用操作</div>
              <el-popover
                popper-class="demo-table-expand"
                placement="right"
                title="更多可用操作"
                trigger="click">
                <slot name="content">
                  <el-button type="success" icon="edit" size="mini" @click="dialogEditOpen(s.row)" v-if="USER.auth.indexOf('business_owner_edit_jichu')!==-1">基础</el-button>
                  <el-button type="info" size="mini" @click="dialogOrderTypeOpen(s.row)" v-if="USER.auth.indexOf('business_owner_edit_dingdan')!==-1">配置订单</el-button>
                  <el-button type="warning" size="mini" @click="dialogStepLibraryOpen(s.row)" v-if="USER.auth.indexOf('business_owner_edit_jihuo')!==-1">集货暂存</el-button>
                </slot>
                <el-button slot="reference" type="info" icon="more" :plain="true" size="mini" class="__reference"></el-button>
              </el-popover>
            </el-tooltip>
          </template>
        </el-table-column>
        <el-form-item label="货主名称" prop="mc">
          <el-input type="text"
                    class="input"
                    v-model="autoVue_table_mc"
                    placeholder="货主名称" spellcheck="false" auto-capitalize="off" auto-complete="off"
                    auto-correct="off"></el-input>
        </el-form-item>
      </s-table>
    </el-card>

    <s-dialog :dialog="dialog" :close="dialogInit">
      <p slot="title">{{dialog.title}}货主</p>
      <el-tabs v-model="dialog.activeName">
        <el-tab-pane label="基础设置" name="1" disabled>
          <s-form :form="formDialog1" ref="formDialog1">
            <el-row>
              <el-col :xs="24" :lg="{span: 11, offset: 0}">
                <el-form-item prop="mc" label="货主名称">
                  <el-input
                    type="text"
                    v-model="formDialog1.mc"
                    placeholder="货主名称"></el-input>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :lg="{span: 11, offset: 1}">
                <el-form-item prop="yxj" label="优先级">
                  <el-select v-model="formDialog1.yxj" placeholder="请选择">
                    <el-option
                      v-for="item in HUOZHU.yxj"
                      :key="item.dictionaryid"
                      :label="item.value"
                      :value="item.dictionaryid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :xs="24" :lg="{span: 11, offset: 0}">
                <el-form-item prop="lxr" label="联系人">
                  <el-input
                    type="text"
                    v-model="formDialog1.lxr"
                    placeholder="联系人"></el-input>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :lg="{span: 11, offset: 1}">
                <el-form-item prop="dz" label="地址">
                  <el-input
                    type="text"
                    v-model="formDialog1.dz"
                    placeholder="地址"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </s-form>
        </el-tab-pane>
        <el-tab-pane label="指定库位" name="2" disabled>
          <el-tree
            :data="dialog.tree"
            ref="tree"
            node-key="key"
            show-checkbox>
          </el-tree>
        </el-tab-pane>
        <el-tab-pane label="规则设置" name="3" disabled>
          <s-form :form="formDialog3" ref="formDialog3">
            <el-form-item prop="sjgzid" label="上架规则">
              <el-select v-model="formDialog3.sjgzid"
                         filterable
                         placeholder="请选择上架规则">
                <el-option
                  v-for="item in dialog.wmsShelfRule"
                  :key="item.dictionaryid"
                  :label="item.value"
                  :value="item.dictionaryid">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item prop="zzgzIds" label="周转规则">
              <el-select v-model="formDialog3.zzgzIds"
                         filterable
                         multiple
                         placeholder="请选择周转规则">
                <el-option
                  v-for="item in dialog.wmsTurnOverRule"
                  :key="item.dictionaryid"
                  :label="item.value"
                  :value="item.dictionaryid">
                </el-option>
              </el-select>
            </el-form-item>
          </s-form>
        </el-tab-pane>
        <el-tab-pane label="订单设置" name="4" disabled>
          <s-form :form="formDialog4" ref="formDialog4">
            <el-row>
              <el-col :xs="24" :lg="{span: 11, offset: 0}">
                <el-form-item prop="slbuck" label="出库规则">
                  <el-select v-model="formDialog4.slbuck" placeholder="请选择">
                    <el-option
                      v-for="item in HUOZHU.slbuck"
                      :key="item.dictionaryid"
                      :label="item.value"
                      :value="item.dictionaryid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :lg="{span: 11, offset: 1}">
                <el-form-item prop="ddsxts" label="订单失效天">
                  <el-input
                    type="text"
                    v-model="formDialog4.ddsxts"
                    placeholder="订单失效天"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :xs="24" :lg="{span: 11, offset: 0}">
                <el-form-item prop="dcfh" label="多次发货">
                  <el-select v-model="formDialog4.dcfh" placeholder="请选择">
                    <el-option
                      v-for="item in HUOZHU.dcfh"
                      :key="item.dictionaryid"
                      :label="item.value"
                      :value="item.dictionaryid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :lg="{span: 11, offset: 1}">
                <el-form-item prop="zyzdqr" label="库内转移">
                  <el-select v-model="formDialog4.zyzdqr" placeholder="请选择">
                    <el-option
                      v-for="item in HUOZHU.zyzdqr"
                      :key="item.dictionaryid"
                      :label="item.value"
                      :value="item.dictionaryid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :xs="24" :lg="{span: 11, offset: 0}">
                <el-form-item prop="bhzdqr" label="补货单">
                  <el-select v-model="formDialog4.bhzdqr" placeholder="请选择">
                    <el-option
                      v-for="item in HUOZHU.bhzdqr"
                      :key="item.dictionaryid"
                      :label="item.value"
                      :value="item.dictionaryid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
          </s-form>
        </el-tab-pane>
        <el-tab-pane label="更多设置" name="5" disabled>
          <s-form :form="formDialog5" ref="formDialog5">
            <el-row>
              <el-col :xs="24" :lg="{span: 11, offset: 0}">
                <el-form-item prop="zjfs" label="质检方式">
                  <el-select v-model="formDialog5.zjfs" placeholder="请选择">
                    <el-option
                      v-for="item in HUOZHU.zjfs"
                      :key="item.dictionaryid"
                      :label="item.value"
                      :value="item.dictionaryid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :lg="{span: 11, offset: 1}">
                <el-form-item prop="kcyj" label="库存预警">
                  <el-select v-model="formDialog5.kcyj" placeholder="请选择">
                    <el-option
                      v-for="item in HUOZHU.kcyj"
                      :key="item.dictionaryid"
                      :label="item.value"
                      :value="item.dictionaryid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :xs="24" :lg="{span: 11, offset: 0}" class="">
                <el-form-item prop="djdps" label="DPS">
                  <el-select v-model="formDialog5.djdps" placeholder="请选择">
                    <el-option
                      v-for="item in HUOZHU.djdps"
                      :key="item.dictionaryid"
                      :label="item.value"
                      :value="item.dictionaryid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :lg="{span: 11, offset: 1}">
                <el-form-item prop="djpda" label="PDA">
                  <el-select v-model="formDialog5.djpda" placeholder="请选择">
                    <el-option
                      v-for="item in HUOZHU.djpda"
                      :key="item.dictionaryid"
                      :label="item.value"
                      :value="item.dictionaryid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :xs="24" :lg="{span: 11, offset: 0}" class="">
                <el-form-item prop="zxqx" label="是否装箱">
                  <el-select v-model="formDialog5.zxqx" placeholder="请选择">
                    <el-option
                      v-for="item in HUOZHU.zxgx"
                      :key="item.dictionaryid"
                      :label="item.value"
                      :value="item.dictionaryid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :lg="{span: 11, offset: 1}" class="">
                <el-form-item prop="sfbh" label="是否补货">
                  <el-select v-model="formDialog5.sfbh" placeholder="请选择">
                    <el-option
                      v-for="item in HUOZHU.sfbh"
                      :key="item.dictionaryid"
                      :label="item.value"
                      :value="item.dictionaryid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :xs="24" :lg="{span: 11, offset: 0}">
                <el-form-item prop="pdwwcqx" label="完成盘点">
                  <el-select v-model="formDialog5.pdwwcqx" placeholder="请选择">
                    <el-option
                      v-for="item in HUOZHU.pdwwcqx"
                      :key="item.dictionaryid"
                      :label="item.value"
                      :value="item.dictionaryid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :lg="{span: 11, offset: 1}" class="">
                <el-form-item prop="ckfh" label="出库复核">
                  <el-select v-model="formDialog5.ckfh" placeholder="请选择">
                    <el-option
                      v-for="item in HUOZHU.ckfh"
                      :key="item.dictionaryid"
                      :label="item.value"
                      :value="item.dictionaryid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :xs="24" :lg="{span: 11, offset: 0}" class="">
                <el-form-item prop="cz" label="称重">
                  <el-select v-model="formDialog5.cz" placeholder="请选择">
                    <el-option
                      v-for="item in HUOZHU.cz"
                      :key="item.dictionaryid"
                      :label="item.value"
                      :value="item.dictionaryid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :lg="{span: 11, offset: 1}" class="">
                <el-form-item prop="fhdymd" label="复核时打印快递面单">
                  <el-select v-model="formDialog5.fhdymd" placeholder="请选择">
                    <el-option
                      v-for="item in HUOZHU.fhdymd"
                      :key="item.dictionaryid"
                      :label="item.value"
                      :value="item.dictionaryid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :xs="24" :lg="{span: 11, offset: 0}" class="">
                <el-form-item prop="zcd" label="装车单">
                  <el-select v-model="formDialog5.zcd" placeholder="请选择">
                    <el-option
                      v-for="item in HUOZHU.zcd"
                      :key="item.dictionaryid"
                      :label="item.value"
                      :value="item.dictionaryid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :lg="{span: 11, offset: 1}" class="">
                <el-form-item prop="cmhpm" label="扫描货品码">
                  <el-select v-model="formDialog5.cmhpm" placeholder="请选择">
                    <el-option
                      v-for="item in HUOZHU.cmhpm"
                      :key="item.dictionaryid"
                      :label="item.value"
                      :value="item.dictionaryid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :xs="24" :lg="{span: 11, offset: 0}" class="">
                <el-form-item prop="smLpn" label="扫描LPN">
                  <el-select v-model="formDialog5.smLpn" placeholder="请选择">
                    <el-option
                      v-for="item in HUOZHU.smLpn"
                      :key="item.dictionaryid"
                      :label="item.value"
                      :value="item.dictionaryid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
          </s-form>
        </el-tab-pane>
      </el-tabs>
      <el-button slot="footer" v-if="dialog.activeName !== '1'" @click="dialogPre">上一页</el-button>
      <el-button slot="footer" type="info" v-if="dialog.activeName !== '5'" @click="dialogNext">下一页</el-button>
      <el-button slot="footer" type="success" v-if="dialog.activeName === '5'" @click="dialogSave">保存</el-button>
    </s-dialog>
    <s-dialog :dialog="dialogEdit" :close="dialogEditInit">
      <p slot="title">{{dialogEdit.title}}货主</p>
      <el-tabs v-model="dialogEdit.activeName">
        <el-tab-pane label="基础设置" name="1" disabled>
          <s-form :form="formDialogEdit1" ref="formDialogEdit1">
            <el-row>
              <el-col :xs="24" :lg="{span: 11, offset: 0}">
                <el-form-item prop="mc" label="货主名称">
                  <el-input
                    type="text"
                    v-model="formDialogEdit1.mc"
                    placeholder="货主名称"></el-input>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :lg="{span: 11, offset: 1}">
                <el-form-item prop="yxj" label="优先级">
                  <el-select v-model="formDialogEdit1.yxj" placeholder="请选择">
                    <el-option
                      v-for="item in HUOZHU.yxj"
                      :key="item.dictionaryid"
                      :label="item.value"
                      :value="item.dictionaryid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :xs="24" :lg="{span: 11, offset: 0}">
                <el-form-item prop="lxr" label="联系人">
                  <el-input
                    type="text"
                    v-model="formDialogEdit1.lxr"
                    placeholder="联系人"></el-input>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :lg="{span: 11, offset: 1}">
                <el-form-item prop="dz" label="地址">
                  <el-input
                    type="text"
                    v-model="formDialogEdit1.dz"
                    placeholder="地址"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </s-form>
        </el-tab-pane>
        <el-tab-pane label="规则设置" name="2" disabled>
          <s-form :form="formDialogEdit2" ref="formDialogEdit2">
            <el-form-item prop="sjgzid" label="上架规则">
              <el-select v-model="formDialogEdit2.sjgzid"
                         filterable
                         placeholder="请选择上架规则">
                <el-option
                  v-for="item in dialog.wmsShelfRule"
                  :key="item.dictionaryid"
                  :label="item.value"
                  :value="item.dictionaryid">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item prop="zzgzIds" label="周转规则">
              <el-select v-model="formDialogEdit2.zzgzIds"
                         filterable
                         multiple
                         placeholder="请选择周转规则">
                <el-option
                  v-for="item in dialog.wmsTurnOverRule"
                  :key="item.dictionaryid"
                  :label="item.value"
                  :value="item.dictionaryid">
                </el-option>
              </el-select>
            </el-form-item>
          </s-form>
        </el-tab-pane>
        <el-tab-pane label="订单设置" name="3" disabled>
          <s-form :form="formDialogEdit3" ref="formDialogEdit3">
            <el-row>
              <el-col :xs="24" :lg="{span: 11, offset: 0}">
                <el-form-item prop="slbuck" label="出库规则">
                  <el-select v-model="formDialogEdit3.slbuck" placeholder="请选择">
                    <el-option
                      v-for="item in HUOZHU.slbuck"
                      :key="item.dictionaryid"
                      :label="item.value"
                      :value="item.dictionaryid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :lg="{span: 11, offset: 1}">
                <el-form-item prop="ddsxts" label="订单失效天">
                  <el-input
                    type="text"
                    v-model="formDialogEdit3.ddsxts"
                    placeholder="订单失效天"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :xs="24" :lg="{span: 11, offset: 0}">
                <el-form-item prop="dcfh" label="多次发货">
                  <el-select v-model="formDialogEdit3.dcfh" placeholder="请选择">
                    <el-option
                      v-for="item in HUOZHU.dcfh"
                      :key="item.dictionaryid"
                      :label="item.value"
                      :value="item.dictionaryid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :lg="{span: 11, offset: 1}">
                <el-form-item prop="zyzdqr" label="库内转移">
                  <el-select v-model="formDialogEdit3.zyzdqr" placeholder="请选择">
                    <el-option
                      v-for="item in HUOZHU.zyzdqr"
                      :key="item.dictionaryid"
                      :label="item.value"
                      :value="item.dictionaryid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :xs="24" :lg="{span: 11, offset: 0}">
                <el-form-item prop="bhzdqr" label="补货单">
                  <el-select v-model="formDialogEdit3.bhzdqr" placeholder="请选择">
                    <el-option
                      v-for="item in HUOZHU.bhzdqr"
                      :key="item.dictionaryid"
                      :label="item.value"
                      :value="item.dictionaryid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
          </s-form>
        </el-tab-pane>
        <el-tab-pane label="更多设置" name="4" disabled>
          <s-form :form="formDialogEdit4" ref="formDialogEdit4">
            <el-row>
              <el-col :xs="24" :lg="{span: 11, offset: 0}">
                <el-form-item prop="zjfs" label="质检方式">
                  <el-select v-model="formDialogEdit4.zjfs" placeholder="请选择">
                    <el-option
                      v-for="item in HUOZHU.zjfs"
                      :key="item.dictionaryid"
                      :label="item.value"
                      :value="item.dictionaryid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :lg="{span: 11, offset: 1}">
                <el-form-item prop="kcyj" label="库存预警">
                  <el-select v-model="formDialogEdit4.kcyj" placeholder="请选择">
                    <el-option
                      v-for="item in HUOZHU.kcyj"
                      :key="item.dictionaryid"
                      :label="item.value"
                      :value="item.dictionaryid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :xs="24" :lg="{span: 11, offset: 0}" class="">
                <el-form-item prop="djdps" label="DPS">
                  <el-select v-model="formDialogEdit4.djdps" placeholder="请选择">
                    <el-option
                      v-for="item in HUOZHU.djdps"
                      :key="item.dictionaryid"
                      :label="item.value"
                      :value="item.dictionaryid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :lg="{span: 11, offset: 1}">
                <el-form-item prop="djpda" label="PDA">
                  <el-select v-model="formDialogEdit4.djpda" placeholder="请选择">
                    <el-option
                      v-for="item in HUOZHU.djpda"
                      :key="item.dictionaryid"
                      :label="item.value"
                      :value="item.dictionaryid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :xs="24" :lg="{span: 11, offset: 0}" class="">
                <el-form-item prop="zxqx" label="是否装箱">
                  <el-select v-model="formDialogEdit4.zxqx" placeholder="请选择">
                    <el-option
                      v-for="item in HUOZHU.zxgx"
                      :key="item.dictionaryid"
                      :label="item.value"
                      :value="item.dictionaryid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :lg="{span: 11, offset: 1}" class="">
                <el-form-item prop="sfbh" label="是否补货">
                  <el-select v-model="formDialogEdit4.sfbh" placeholder="请选择">
                    <el-option
                      v-for="item in HUOZHU.sfbh"
                      :key="item.dictionaryid"
                      :label="item.value"
                      :value="item.dictionaryid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :xs="24" :lg="{span: 11, offset: 0}">
                <el-form-item prop="pdwwcqx" label="完成盘点">
                  <el-select v-model="formDialogEdit4.pdwwcqx" placeholder="请选择">
                    <el-option
                      v-for="item in HUOZHU.pdwwcqx"
                      :key="item.dictionaryid"
                      :label="item.value"
                      :value="item.dictionaryid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :lg="{span: 11, offset: 1}" class="">
                <el-form-item prop="ckfh" label="出库复核">
                  <el-select v-model="formDialogEdit4.ckfh" placeholder="请选择">
                    <el-option
                      v-for="item in HUOZHU.ckfh"
                      :key="item.dictionaryid"
                      :label="item.value"
                      :value="item.dictionaryid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :xs="24" :lg="{span: 11, offset: 0}" class="">
                <el-form-item prop="cz" label="称重">
                  <el-select v-model="formDialogEdit4.cz" placeholder="请选择">
                    <el-option
                      v-for="item in HUOZHU.cz"
                      :key="item.dictionaryid"
                      :label="item.value"
                      :value="item.dictionaryid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :lg="{span: 11, offset: 1}" class="">
                <el-form-item prop="fhdymd" label="复核时打印快递面单">
                  <el-select v-model="formDialogEdit4.fhdymd" placeholder="请选择">
                    <el-option
                      v-for="item in HUOZHU.fhdymd"
                      :key="item.dictionaryid"
                      :label="item.value"
                      :value="item.dictionaryid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :xs="24" :lg="{span: 11, offset: 0}" class="">
                <el-form-item prop="zcd" label="装车单">
                  <el-select v-model="formDialogEdit4.zcd" placeholder="请选择">
                    <el-option
                      v-for="item in HUOZHU.zcd"
                      :key="item.dictionaryid"
                      :label="item.value"
                      :value="item.dictionaryid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :lg="{span: 11, offset: 1}" class="">
                <el-form-item prop="cmhpm" label="扫描货品码">
                  <el-select v-model="formDialogEdit4.cmhpm" placeholder="请选择">
                    <el-option
                      v-for="item in HUOZHU.cmhpm"
                      :key="item.dictionaryid"
                      :label="item.value"
                      :value="item.dictionaryid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :xs="24" :lg="{span: 11, offset: 0}" class="">
                <el-form-item prop="smLpn" label="扫描LPN">
                  <el-select v-model="formDialogEdit4.smLpn" placeholder="请选择">
                    <el-option
                      v-for="item in HUOZHU.smLpn"
                      :key="item.dictionaryid"
                      :label="item.value"
                      :value="item.dictionaryid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
          </s-form>
        </el-tab-pane>
      </el-tabs>

      <el-button slot="footer" v-if="dialogEdit.activeName !== '1'" @click="dialogEditPre">上一页</el-button>
      <el-button slot="footer" type="info" v-if="dialogEdit.activeName !== '4'" @click="dialogEditNext">下一页</el-button>
      <el-button slot="footer" type="success" v-if="dialogEdit.activeName === '4'" @click="dialogEditSave">保存</el-button>
    </s-dialog>
    <s-dialog :dialog="dialogLibrary" :close="dialogLibraryInit">
      <p slot="title">货主拥有库位 <span>{{dialogLibrary.row.mc}}</span></p>
      <div style="display: flex; justify-content: center">
        <div style="position: relative; top: 0; left: 15%;">
          <el-tree
            class="el_tree"
            :data="dialogLibrary.tree.data"
            :ref="dialogLibrary.tree.ref"
            node-key="key"
            @node-click="nodeclick"
            @check-change="checkcilck"
            :default-checked-keys="dialogLibrary.tree.ids"
            show-checkbox>
          </el-tree>
        </div>
        <div style="width: 70%;">
          <el-table
            style="width: 40%;height: 90%;margin: 0 auto;"
            :data="this.tableTree.data"
            @select="tableselect"
            @select-all="tableselectall"
            ref="treetable">
            <el-table-column
              type="selection"
              width="55">
            </el-table-column>
            <el-table-column
              prop="mc"
              label="库位"
              width="200">
            </el-table-column>
          </el-table>
          <div style="width: 100%; text-align: center;">
            <p></p>
            <el-pagination
              @size-change="sizeChange"
              @current-change="currentChange"
              :page-sizes="[10, 20, 30, 50, 100]"
              :page-size="10"
              :layout="tableTree.layout"
              :current-page="currentPage"
              :total="tableTree.total">
            </el-pagination>
          </div>
        </div>
      </div>

      <el-button slot="footer" type="success" @click="dialogLibrarySave">保存</el-button>
    </s-dialog>
    <s-dialog :dialog="dialogOrderType" :close="dialogOrderTypeInit">
      <p slot="title">订单类型 <span>{{dialogOrderType.row.mc}}</span></p>
      <s-table
        :multiSelect="true"
        :table="tableOrderType"
        ref="tableOrderType"
        @http="tableWatch">
        <el-form-item label="订单类型" prop="ddlx">
          <el-input type="text"
                    class="input"
                    v-model="autoVue_tableOrderType_ddlx"
                    placeholder="订单类型" spellcheck="false" auto-capitalize="off" auto-complete="off"
                    auto-correct="off"></el-input>
        </el-form-item>
        <el-form-item label="订单分类" prop="fl">
          <el-select v-model="autoVue_tableOrderType_fl"
                     placeholder="订单分类">
            <el-option
              label="全部"
              value=""></el-option>
            <el-option
              label="入库单"
              value="0"></el-option>
            <el-option
              label="出库单"
              value="1"></el-option>
          </el-select>
        </el-form-item>
      </s-table>
      <el-button slot="footer" type="success" @click="dialogOrderTypeSave">保存</el-button>
    </s-dialog>
    <s-dialog :dialog="dialogStepLibrary" :close="dialogStepLibraryInit">
      <p slot="title">配置集货库位和暂存库位<span>{{dialogStepLibrary.row.mc}}</span></p>
      <s-form :form="formDialogStepLibrary" ref="formDialogStepLibrary">
        <el-row>
          <el-col :xs="24" :lg="{span: 11, offset: 0}">
            <el-form-item prop="jhqkwMc" label="集货库位">
              <el-input
                type="text"
                v-model="formDialogStepLibrary.jhqkwMc"
                placeholder="标题行号"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :lg="{span: 11, offset: 1}">
            <el-form-item prop="djcwMc" label="暂存库位">
              <el-input
                type="text"
                v-model="formDialogStepLibrary.djcwMc"
                placeholder="取值行号"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </s-form>
      <el-button slot="footer" type="success" @click="dialogStepLibrarySave">保存</el-button>
    </s-dialog>
  </div>
</template>

<script>
  /* eslint-disable no-multiple-empty-lines,no-trailing-spaces */

  import {AutoVue, AutoPromise} from '~/plugins/Tools';

  function __form1 () {
    return {
      mc: { value: '', rule: [ 'vNull' ], cRemarks: '' },
      lxr: { value: '', rule: [ 'vNull' ], cRemarks: '' },
      dz: { value: '', rule: [ 'vNull' ], cRemarks: '' },
      yxj: { value: '0', rule: [ 'vNull__change' ], cRemarks: '' },
    };
  }
  function __form3 () {
    return {
      sjgzid: { value: '', rule: [ 'vNull' ], cRemarks: '' },
      zzgzIds: { value: [], rule: [ 'vNull' ], cRemarks: '' },
    };
  }
  function __form4 () {
    return {
      slbuck: { value: '1', rule: [ 'vNull' ], cRemarks: '' },
      dcfh: { value: '1', rule: [ 'vNull' ], cRemarks: '' },
      zyzdqr: { value: '0', rule: [ 'vNull' ], cRemarks: '' },
      bhzdqr: { value: '0', rule: [ 'vNull' ], cRemarks: '' },
      ddsxts: { value: '', rule: [ 'vNull', 'vNumberZ', 'vWS4' ], cRemarks: '' },
    };
  }
  function __form5 () {
    return {
      shfk: { value: '0', rule: [ 'vNull' ], cRemarks: '' },
      shzdmp: { value: '1', rule: [ 'vNull' ], cRemarks: '' },
      shscpch: { value: '0', rule: [ 'vNull' ], cRemarks: '' },
      shscscrq: { value: '0', rule: [ 'vNull' ], cRemarks: '' },
      kcyj: { value: '0', rule: [ 'vNull' ], cRemarks: '' },
      pdwwcqx: { value: '0', rule: [ 'vNull' ], cRemarks: '' },
      djpda: { value: '0', rule: [ 'vNull' ], cRemarks: '' },
      sfbh: { value: '0', rule: [ 'vNull__change' ], cRemarks: '' },
      zjfs: { value: '0', rule: [ 'vNull__change' ], cRemarks: '' },
      zxqx: { value: '0', rule: [ 'vNull__change' ], cRemarks: '' },
      djdps: { value: '0', rule: ['vNull__change'], cRemarks: '' },
      ckfh: { value: '0', rule: ['vNull__change'], cRemarks: '' },
      cz: { value: '0', rule: ['vNull__change'], cRemarks: '' },
      fhdymd: { value: '0', rule: ['vNull__change'], cRemarks: '' },
      zcd: { value: '0', rule: ['vNull__change'], cRemarks: '' },
      cmhpm: { value: '0', rule: ['vNull__change'], cRemarks: '' },
      smLpn: { value: '0', rule: ['vNull__change'], cRemarks: '' },
    };
  }
  function __formDialogStepLibrary () {
    return {
      jhqkwMc: { value: '', rule: [ 'vNull' ], cRemarks: '' },
      djcwMc: { value: '', rule: [ 'vNull' ], cRemarks: '' },
    };
  }
  function __formEdit (number) {
    switch (number) {
    case 1:
      return {
        mc: { value: '', rule: [ 'vNull' ], cRemarks: '' },
        lxr: { value: '', rule: [ 'vNull' ], cRemarks: '' },
        dz: { value: '', rule: [ 'vNull' ], cRemarks: '' },
        yxj: { value: '0', rule: [ 'vNull__change' ], cRemarks: '' },
      };
    case 2:
      return {
        sjgzid: { value: '', rule: [ 'vNull' ], cRemarks: '' },
        zzgzIds: { value: [], rule: [ 'vNull' ], cRemarks: '' },
      };
    case 3:
      return {
        slbuck: { value: '1', rule: [ 'vNull' ], cRemarks: '' },
        dcfh: { value: '1', rule: [ 'vNull' ], cRemarks: '' },
        zyzdqr: { value: '0', rule: [ 'vNull' ], cRemarks: '' },
        bhzdqr: { value: '0', rule: [ 'vNull' ], cRemarks: '' },
        ddsxts: { value: '', rule: [ 'vNull', 'vNumberZ', 'vWS4' ], cRemarks: '' },
      };
    case 4:
      return __form5();
    }
  }
  export default AutoVue({
    name: 'business_owner-FEcarWms',
    head: {
      'title': '货主管理',
      'meta': [
        { 'hid': 'description', 'name': 'description', 'content': '乐速科技平台 货主 查看货主信息' },
      ],
    },
    data: {
      table: {
        column: [ { label: '货主名称',
          prop: 'mc',
          minWidth: '0px',
          cRemarks: '',
          search: true },
        { label: '联系人',
          prop: 'lxr',
          minWidth: '0px',
          cRemarks: '',
          search: false },
        { label: '地址',
          prop: 'dz',
          minWidth: '0px',
          cRemarks: '',
          search: false },
        { label: '上架规则',
          prop: 'show_sjgzid',
          minWidth: '0px',
          cRemarks: '',
          search: false },
        { label: '周转规则',
          prop: 'show_zzgzIds',
          minWidth: '0px',
          cRemarks: '',
          search: false },
        { label: '出库规则',
          prop: 'show_slbuck',
          minWidth: '0px',
          cRemarks: '',
          search: false },
        { label: '多次发货',
          prop: 'show_dcfh',
          minWidth: '0px',
          cRemarks: '',
          search: false },
        { label: '库内转移',
          prop: 'show_zyzdqr',
          minWidth: '0px',
          cRemarks: '',
          search: false },
        { label: '补货单',
          prop: 'show_bhzdqr',
          minWidth: '0px',
          cRemarks: '',
          search: false },
        { label: '失效天数',
          prop: 'ddsxts',
          minWidth: '0px',
          cRemarks: '',
          search: false },
        { label: '收货反馈',
          prop: 'show_shfk',
          minWidth: '0px',
          cRemarks: '',
          search: false },
        { label: '自动码盘',
          prop: 'show_shzdmp',
          minWidth: '0px',
          cRemarks: '',
          search: false },
        { label: '批次号',
          prop: 'show_shscpch',
          minWidth: '0px',
          cRemarks: '',
          search: false },
        { label: '是否装箱',
          prop: 'show_zxqx',
          minWidth: '0px',
          cRemarks: '',
          search: false },
        { label: '生产日期',
          prop: 'show_shscscrq',
          minWidth: '0px',
          cRemarks: '',
          search: false },
        { label: '库存预警',
          prop: 'show_kcyj',
          minWidth: '0px',
          cRemarks: '',
          search: false },
        { label: '完成盘点',
          prop: 'show_pdwwcqx',
          minWidth: '0px',
          cRemarks: '',
          search: false },
        { label: 'PDA',
          prop: 'show_djpda',
          minWidth: '0px',
          cRemarks: '',
          search: false },
        { label: 'DPS',
          prop: 'show_djdps',
          minWidth: '0px',
          cRemarks: '',
          search: false },
        { label: '出库复核',
          prop: 'show_ckfh',
          minWidth: '0px',
          cRemarks: '',
          search: false },
        { label: '称重',
          prop: 'show_cz',
          minWidth: '0px',
          cRemarks: '',
          search: false },
        { label: '快递面单',
          prop: 'show_fhdymd',
          minWidth: '0px',
          cRemarks: '',
          search: false },
        { label: '装车单',
          prop: 'show_zcd',
          minWidth: '0px',
          cRemarks: '',
          search: false },
        { label: '扫描货品码',
          prop: 'show_cmhpm',
          minWidth: '0px',
          cRemarks: '',
          search: false },
        { label: '扫描LPN',
          prop: 'show_smLpn',
          minWidth: '0px',
          cRemarks: '',
          search: false },
        ],
        url: '/wmsOwner/list',
        key: 'id',
        tableColumn: 3,
        muti: false,
      },
      formDialog1: __form1(),
      formDialog3: __form3(),
      formDialog4: __form4(),
      formDialog5: __form5(),
      dialog: {
        title: '新增',
        size: 'large',
        tree: [],
        wmsShelfRule: [],
        wmsTurnOverRule: [],
        activeName: '1',
      },
      dialogEdit: {
        title: '修改',
        size: 'large',
        row: {},
        activeName: '1',
      },
      formDialogEdit1: __formEdit(1),
      formDialogEdit2: __formEdit(2),
      formDialogEdit3: __formEdit(3),
      formDialogEdit4: __formEdit(4),
      dialogLibrary: {
        row: {},
        tree: {
          ref: 'libraryTree',
          data: [],
          ids: [],
        },
      },
      dialogOrderType: {
        row: {},
      },
      dialogStepLibrary: {
        row: {},
      },
      formDialogStepLibrary: __formDialogStepLibrary(),
      tableOrderType: {
        column: [
          { label: '货主名称',
            prop: 'mc',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '订单类型',
            prop: 'ddlx',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '订单分类',
            prop: 'show_fl',
            minWidth: '0px',
            cRemarks: '0入库单 1出库单',
            search: true },
          { label: '是否采集SN码',
            prop: 'show_cjsn',
            minWidth: '0px',
            cRemarks: '0不采集 1采集',
            search: false },
        ],
        baseUrl: '/wmsOwner/getOrderTypeByHzId/',
        url: '/',
        key: 'id',
        tableColumn: 3,
        muti: false,
      },


      tableTree: {
        column: [
          {'label': '名称', 'prop': 'mc', 'minWidth': '0px'},
        ],
        key: 'id',
        url: '',
      },
      currentPage: 1,
      treeSate: '',
      treeSatatype: [], // tree的选中ids及状态
      treedata: [],
      treeCurrentids: [],
      nodeClickKey: '',
      kuqubeginids: '', // 查询库位时初始ids
      tcheckboxids: [], // table勾选的ids 使用tableCheckboxids命名时报错
      counter: 0,
    },
    transition: 'slide-fade',
    store: ['HUOZHU', 'USER', 'DICTIONARY_huozhu'],
    methods: {
      // 分页
      sizeChange (val) {
        this.tableTree.rows = val;
        this.tableWatch('tableTree');
      },
      currentChange (val) {
        this.tableTree.page = val;
        this.tableWatch('tableTree');
        setTimeout(() => {
          this.tableRendererjudge();
        }, 800);
      },
      dialogInit () {
        this.dialog.activeName = '1';
        this.formDialog1 = {
          ...this.formDialog1,
          ...this.ObjectClone(__form1()),
        };
        this.formDialog3 = {
          ...this.formDialog3,
          ...this.ObjectClone(__form3()),
        };
        this.formDialog4 = {
          ...this.formDialog4,
          ...this.ObjectClone(__form4()),
        };
        this.formDialog5 = {
          ...this.formDialog5,
          ...this.ObjectClone(__form5()),
        };
        this.resetFields('formDialog1');
        this.resetFields('formDialog3');
        this.resetFields('formDialog4');
        this.resetFields('formDialog5');
      },
      async dialogOpen () {
        await AutoPromise([
          async () => {
            if (!this.DICTIONARY_huozhu) {
              await this.USE('DICTIONARY_huozhu');
            }
          },
          async () => {
            this.dialog.tree = await this.get('/wmsOwner/getLibraryareaTree');
          },
          async () => {
            if (this.dialog.wmsShelfRule.length === 0) {
              this.dialog.wmsShelfRule = await this.get('/wmsShelfRule/getDictionary');
            }
          },
          async () => {
            if (this.dialog.wmsTurnOverRule.length === 0) {
              this.dialog.wmsTurnOverRule = await this.get('/wmsTurnOverRule/getDictionary');
            }
          },
        ]);
        this.dialog.visible = true;
      },
      dialogSave () {
        this.VALIDATE('formDialog5', async option => {
          let tree = this.$refs.tree;
          let ids = tree.getCheckedKeys(true);
          let idsParent = [];
          let addIdsParent = key => {
            let parent = tree.store.nodesMap[key].parent;
            if (typeof parent.key === 'undefined' || idsParent.indexOf(parent.key) !== -1) return;
            idsParent.push(parent.key);
            addIdsParent(parent.key);
          };
          for (let item of ids) {
            addIdsParent(item);
          }
          ids = [...ids, ...idsParent];
          option.librarypositionIds = ids;
          let zzgzIds = '';
          this.formDialog3.zzgzIds.forEach(value => {
            zzgzIds += value + ',';
          });
          zzgzIds = zzgzIds.substring(0, zzgzIds.length - 1);
          let json = {
            ...this.FORMOPTION('formDialog1'),
            ...this.FORMOPTION('formDialog3'),
            ...this.FORMOPTION('formDialog4'),
            ...this.FORMOPTION('formDialog5'),
            ...this.FORMOPTION('formDialog6'),
            ...option,
            zzgzIds,
          };
          try {
            let {data} = await this.post('/wmsOwner/add', json);
            this.table.data = [await this.get('/wmsOwner/getWmsOwnerById/' + data.id), ...this.table.data];
            this.table.total++;
            this.dialogInit();
            this.dialogStepLibraryOpen(data);
            this.dialog.visible = false;
          } catch (err) {
            console.log(err);
          }
        });
      },
      dialogPre () {
        this.dialog.activeName = parseInt(this.dialog.activeName) - 1 + '';
      },
      dialogNext () {
        if (this.dialog.activeName === '2') {
          let ids = this.$refs.tree.getCheckedKeys(true);
          if (ids.length < 1) {
            this.$alert('请至少选择一个库位！', '提示');
          } else {
            this.dialog.activeName = parseInt(this.dialog.activeName) + 1 + '';
          }
        } else {
          this.VALIDATE('formDialog' + this.dialog.activeName, option => {
            this.dialog.activeName = parseInt(this.dialog.activeName) + 1 + '';
          });
        }
      },
      dialogEditInit () {
        this.dialogEdit.row = {};
        this.dialogEdit.activeName = '1';
        this.formDialogEdit1 = {
          ...this.formDialogEdit1,
          ...this.ObjectClone(__formEdit(1)),
        };
        this.formDialogEdit2 = {
          ...this.formDialogEdit2,
          ...this.ObjectClone(__formEdit(2)),
        };
        this.formDialogEdit3 = {
          ...this.formDialogEdit3,
          ...this.ObjectClone(__formEdit(3)),
        };
        this.formDialogEdit4 = {
          ...this.formDialogEdit4,
          ...this.ObjectClone(__formEdit(4)),
        };
        this.formDialogEdit5 = {
          ...this.formDialogEdit5,
          ...this.ObjectClone(__formEdit(5)),
        };
        this.resetFields('formDialogEdit1');
        this.resetFields('formDialogEdit2');
        this.resetFields('formDialogEdit3');
        this.resetFields('formDialogEdit4');
        this.resetFields('formDialogEdit5');
      },

      // 点击查看打开dialog
      async dialogLibraryOpen (row) {
        this.dialogLibrary.visible = true;
        this.tableClear('tableTree');
        this.treeSate = '';
        this.treeSatatype = [];
        this.treedata = [];
        this.treeCurrentids = [];
        this.nodeClickKey = '';
        this.kuqubeginids = '';
        this.tcheckboxids = [];
        this.counter = 0;

        // 请求库区数据
        // let {data, ids} = await this.get('/wmsOwner/selectPostionBySshzidOrFree/' + row.id);
        let {ids, libraryAreas} = await this.get('/wmsOwner/getKQ/' + row.id);

        // treedata：所有tree节点数据，treeids：初始要勾选的tree的ids 。
        let treedata = [];
        let treeids = [];
        let treesate = [];

        // 获取初始要勾选的tree的ids 。
        ids.forEach(function (item) {
          treeids.push(item.id);
          treesate.push({'id': item.id, 'sate': item.sate});
        });

        // 记录初始库区ids
        this.treeCurrentids.push(...treeids);

        // 统计tree的选中ids及状态，点击table的checkbox时要修改这个状态
        this.treeSatatype = treesate;

        // 转换为符合tree的数据格式,并且禁用所有checkbox
        libraryAreas.forEach(function (item) {
          treedata.push({'key': item.id, 'label': item.mc, 'disabled': true});
        });
        this.treedata = treedata;
        this.dialogLibrary.row = row;

        // 控制tree的checkbox渲染
        this.rendererTree();
      },

      // 渲染树的勾选
      rendererTree () {
        let treedata = this.treedata;
        let treeids = [];

        // 给勾选的ids追加状态
        this.treeSatatype.forEach(function (index) {
          treedata.forEach(function (item) {
            if (item.key === index.id) {
              switch (index.sate) {
              case 1:
                if (item['label'].indexOf(' ') < 0) {
                  item['label'] = item['label'] + ' 部分';
                } else {
                  item['label'] = item['label'].substring(0, item['label'].indexOf(' ')) + ' 部分';
                }
                break;
              case 2:
                if (item['label'].indexOf(' ') < 0) {
                  item['label'] = item['label'] + ' 全部';
                } else {
                  item['label'] = item['label'].substring(0, item['label'].indexOf(' ')) + ' 全部';
                }
                break;
              }
            }
          });
          treeids.push(index.id);
        });

        let treeSatatype = this.treeSatatype;
        treedata.forEach((item, index) => {
          let type = treeSatatype.some(function (iitem) {
            return item.key === iitem.id;
          });
          if (!type) {
            // treedata[index]['label'] = item['label'].substring(0, item['label'].indexOf(' '));
            if (treedata[index]['label'].indexOf(' ') > 0) {
              treedata[index]['label'] = item['label'].substring(0, item['label'].indexOf(' '));
            }
          }
        });
        this.$nextTick(() => {
          this.dialogLibrary.tree.data = treedata;
          this.$refs[this.dialogLibrary.tree.ref].setCheckedKeys(treeids);
        });
      },

      // tree被点击时的回调
      nodeclick (object, node, elem) {
        console.log('nnnnnnnnnnod', node);
        // 获取当前被点击的节点的key(即id)
        this.nodeClickKey = node.key;

        this.tableTree.url = '/wmsOwner/getKW';
        this.tableTree.option.sskqid = node.key; // 库区id
        // this.tableTree.option.sshzid = this.dialogLibrary.row.id; // 货主id
        this.tableTree.option.sshzid = this.dialogLibrary.row.id;

        this.tableWatch('tableTree');
        setTimeout(() => {
          let beginids = this.tableTree.response.ids;
          let tablenumber = this.tableTree.response.totals;
          let originalIds = [];
          beginids.forEach(function (item, index) {
            originalIds.push(item.id);
          });
          if (this.tcheckboxids.length === 0) {
            this.tcheckboxids.push({'key': node.key, 'value': originalIds, 'number': tablenumber});
          } else {
            let type = this.tcheckboxids.some(function (item) {
              return item.key === node.key;
            });
            if (!type) {
              this.tcheckboxids.push({'key': node.key, 'value': originalIds, 'number': tablenumber});
            }
          }

          let nodekey = node.key;
          let kuqubeginids = {};
          if (this.kuqubeginids !== '') {
            kuqubeginids = JSON.parse(this.kuqubeginids);
          }
          kuqubeginids[nodekey] = originalIds;
          this.kuqubeginids = JSON.stringify(kuqubeginids);
          // 先禁用所哟checkbox，然后解开当前的
          let treeDATA = this.treedata;
          treeDATA.forEach((item, index) => {
            if (item.key === node.key) {
              this.treedata[index]['disabled'] = false;
            } else {
              this.treedata[index]['disabled'] = true;
            }
          });
          this.tableRendererjudge();
        }, 800);
      },

      tableRendererjudge () {
        let nodeClickKey = this.nodeClickKey; // 当前被点击的tree的id
        let currentids = [];
        let currentindex;
        console.log('进入了tableRendererjudge');

        // table勾选的ids,开始为初始化的table的ids
        this.tcheckboxids.forEach(function (item, index) {
          if (item.key === nodeClickKey) {
            currentids = item.value;
            currentindex = index;
          }
        });
        let tabledata = this.tableTree.data;
        let checkarray = [];
        if (currentids.length !== 0) {
          for (let i = 0; i < tabledata.length; i++) {
            for (let ii = 0; ii < currentids.length; ii++) {
              if (tabledata[i].id === currentids[ii]) {
                checkarray.push(tabledata[i]);
                break;
              }
            }
          }
          this.checked(checkarray);
        } else {
          this.checked();
        }
      },

      // Tree的checkbox被点击
      checkcilck (node, type) {
        console.log('复选框被点击');
        let tablecheckboxids = [];
        let currkeyindexs;
        let treesatatype = this.treeSatatype;

        this.tcheckboxids.forEach((item, index) => {
          if (item.key === this.nodeClickKey) {
            tablecheckboxids = item.value;
            currkeyindexs = index;
          }
        });

        // 判断该复选框对应的节点是否为被点击状态
        if (this.nodeClickKey === node.key) {
          if (type) {
            let nodeCLICKKEY = this.nodeClickKey;
            // 判断该id在this.treeSatatype中是否存在，如果不存在则全选
            let tttype = this.treeSatatype.some(function (item) {
              return item.id === nodeCLICKKEY;
            });
            if (!tttype) {
              // this.tcheckboxids[currkeyindexs].value
              console.log('全选', this.tcheckboxids);
              let allkuweiIds = [];
              this.tableTree.response.positionList.forEach(function (item) {
                allkuweiIds.push(item.id);
              });
              // 将所有库位ids赋给 this.tcheckboxids
              this.tcheckboxids[currkeyindexs].value = [];
              this.tcheckboxids[currkeyindexs].value = allkuweiIds;
              // 设置tree的状态
              //              treesatatype.forEach((item, index) => {
              //                console.log('iiiiiiiiiiiiiiiii', item.id, nodeCLICKKEY);
              //                if (item.id === nodeCLICKKEY) {
              //                  // this.treeSatatype[index].sate = 2;
              //
              //                }
              //              });
              this.treeSatatype.push({'id': nodeCLICKKEY, 'sate': 2});
              this.tableRendererjudge();
              this.rendererTree();
            }
          } else {
            console.log('全不选', this.tcheckboxids[currkeyindexs].value);
            let treeSatatype = this.treeSatatype;
            for (let i = 0; i < treeSatatype.length; i++) {
              if (treeSatatype[i].id === node.key) {
                this.treeSatatype.splice(i, 1);
              }
            }
            this.tcheckboxids[currkeyindexs].value = [];
            this.tableRendererjudge();
            this.rendererTree();
          }
        }
      },

      // table的CheckBox触发
      tableselect (selection, row) {
        // selection：表格中当前所有被选中的CheckBox，row：当前CheckBox被点击的行
        console.log('selection, row', selection);

        let response = this.tableTree.response;
        let tableTreeData = this.tableTree.data;
        let checkDifferentids = [];
        let nocheckDifferentids = [];
        let tcheckboxids = this.tcheckboxids;
        let kuqubeginids = JSON.parse(this.kuqubeginids);

        // 获取
        tableTreeData.forEach(function (item) {
          selection.forEach(function (check) {
            if (item.id === check.id) {
              checkDifferentids.push(check.id);
            }
          });
        });
        // 获取差集
        let nocheckidsdata = tableTreeData.filter(key => !selection.includes(key));
        nocheckDifferentids = nocheckidsdata.map(function (item) {
          return item.id;
        });

        let tableNumber = response.totals;// Table数量
        let ClickKey = this.nodeClickKey;// 当前被点击的tree的id

        // this.tcheckboxids[ClickKey] 此时的table的ids
        // let tablecheckboxids = this.tcheckboxids[ClickKey];
        let tablecheckboxids = [];
        let currkeyindexs;
        this.tcheckboxids.forEach(function (item, index) {
          if (item.key === ClickKey) {
            tablecheckboxids = item.value;
            currkeyindexs = index;
          }
        });

        console.log('checkDifferentids', checkDifferentids);
        console.log('nocheckDifferentids', nocheckDifferentids);

        // 如果ids中有checkDiffids的就不动，如果没有就添加
        // 如果ids中没有nocheckDiffids就不动，如果有就去掉
        if (checkDifferentids.length > 0) {
          for (let ii = 0; ii < checkDifferentids.length; ii++) {
            let iids = checkDifferentids[ii];
            let type = tablecheckboxids.some(function (item, index, array) {
              return item === iids;
            });
            if (!type) {
              this.tcheckboxids[currkeyindexs].value.push(iids);
            }
          }
        }
        if (nocheckDifferentids.length > 0) {
          for (let ii in nocheckDifferentids) {
            let iids = nocheckDifferentids[ii];
            let index;
            for (let i in tablecheckboxids) {
              if (tablecheckboxids[i] === iids) {
                this.tcheckboxids[currkeyindexs].value.splice(i, 1);
              }
            }
          }
        }

        // 获取此时的库位ids的长度
        let nowvalue = tcheckboxids[currkeyindexs].value;
        let number = tcheckboxids[currkeyindexs].number;
        let beginvalue = kuqubeginids[ClickKey];
        let treesata = this.treeSatatype;


        // 响应库位的状态
        // 首先判断treesata中有没有此id，如果没有直接添加，如果有进循环
        let havecurrentid = treesata.some(function (item) {
          return item.id === ClickKey;
        });
        if (havecurrentid) {
          for (let index = 0; index < treesata.length; index++) {
            let item = treesata[index];
            if (item.id === ClickKey) {
              console.log('此条是当前');
              if (nowvalue.length === 0) {
                this.treeSatatype.splice(index, 1);
                this.rendererTree();
              }
              if (nowvalue.length > 0 && nowvalue.length < number) {
                this.treeSatatype[index].sate = 1;
                this.rendererTree();
              }
              if (nowvalue.length === number) {
                this.treeSatatype[index].sate = 2;
                this.rendererTree();
              }
            }
          }
        } else {
          this.treeSatatype.push({'id': ClickKey, 'sate': 1});
          this.rendererTree();
        }
        console.log('this.treeSatatype', JSON.stringify(this.treeSatatype));
        console.log('tcheckboxids[ClickKey]', this.tcheckboxids[currkeyindexs]);
      },

      // table的当页全选CheckBox触发
      tableselectall (selection) {
        console.log('table的当页全选CheckBox触发selection', selection);
        this.tableselect(selection);
      },

      // checked方法
      checked (rows) {
        if (rows) {
          rows.forEach(row => {
            this.$refs.treetable.toggleRowSelection(row);
          });
        } else {
          this.$refs.treetable.clearSelection();
        }
      },

      // 保存方法
      async dialogLibrarySave () {
        console.log('保存方法保存方法', this.tcheckboxids.length);

        if (this.tcheckboxids.length !== 0) {
          // 最终勾选的库区的ids
          let currentKUQUIDS = this.$refs[this.dialogLibrary.tree.ref].getCheckedKeys();
          // 初始勾选的库区ids
          let beginKUQUIDS = this.treeCurrentids;

          // 初始勾选的库位ids（是JSON）
          // let beginwuweiids = '';
          let beginKUWEIIDS = JSON.parse(this.kuqubeginids);
          // 最终勾选的库位的ids（是数组）
          let currentKUWEIIDS = this.tcheckboxids;

          let xuanzhongkuwei = [];
          let jiechukuwei = [];
          let xuanzhongkuqu = [];
          let jiechukuqu = [];

          for (let iindex = 0; iindex < currentKUWEIIDS.length; iindex++) {
            let indexkey = currentKUWEIIDS[iindex].key;
            let indexids = currentKUWEIIDS[iindex].value;// 最后勾选的库位ids
            let tablenumber = currentKUWEIIDS[iindex].number;// tablenumber
            let beginids = beginKUWEIIDS[indexkey]; // 初始勾选的库位ids

            // 判断当最后勾选的库位ids与初始勾选的库位ids，数量不同，
            if (indexids.length !== beginids.length) {
              if (beginids.length === tablenumber) { // 如果开始为全选
                if (indexids.length > 0) { // 最后为部分选中,
                  // 传取消勾选的库位ids,获取所有中缺失的
                  let iiids = [];
                  beginids.forEach(function (item) {
                    let type = indexids.some(function (index) {
                      return item === index;
                    });
                    if (!type) {
                      iiids.push(item);
                    }
                  });
                  jiechukuwei.push(...iiids);
                }
                if (indexids.length === 0) { // 最后为全不选
                  // 取消勾选的库区id
                  jiechukuqu.push(indexkey);
                }
              }
              if (beginids.length === 0) { // 开始为全不选
                if (indexids.length > 0 && indexids.length < tablenumber) { // 最后为部分选中
                  // 传增加勾选的库位ids
                  xuanzhongkuwei.push(...indexids);
                }
                if (indexids.length === tablenumber) { // 最后为全选
                  // 增加勾选的库区id
                  xuanzhongkuqu.push(indexkey);
                }
              }
              if (beginids.length > 0 && beginids.length < tablenumber) { // 开始为部分选
                if (indexids.length === 0) { // 最后为全不选
                  // 取消勾选的库区id
                  jiechukuqu.push(indexkey);
                }
                if (indexids.length === tablenumber) { // 最后为全选
                  // 增加勾选的库区id
                  xuanzhongkuqu.push(indexkey);
                }
                if (indexids.length > 0 && indexids.length < tablenumber) { // 最后为部分选
                  // 互相遍历
                  // 如果最后没有而开始有，说明是取消的
                  for (let i = 0; i < beginids.length; i++) {
                    let type = indexids.some(function (item) {
                      return item === beginids[i];
                    });
                    if (!type) {
                      jiechukuwei.push(beginids[i]);
                    }
                  }
                  // 如果最后有而开始没有，说明是新增的
                  for (let i = 0; i < indexids.length; i++) {
                    let type = beginids.some(function (item) {
                      return item === indexids[i];
                    });
                    if (!type) {
                      console.log(indexids[i]);
                      xuanzhongkuwei.push(indexids[i]);
                    }
                  }
                }
              }
            }

            // 判断当最后勾选的库位ids与初始勾选的库位ids，数量不同，
            let jilutype = [];
            if (indexids.length === beginids.length) {
              // 如果内容完全相同，说明没有变化，则不管，如果内容不同，则传值
              for (let i = 0; i < beginids.length; i++) {
                let type = beginids.some(function (item) {
                  return item === indexids[i];
                });
                jilutype.push(type);
              }
              let zuizhogntype = jilutype.every(function (item) {
                return item;
              });

              if (!zuizhogntype) { // 说明两个数组不相同，互相遍历
                console.log('说明两个数组不相同，互相遍历');
                // 如果最后没有而开始有，说明是取消的
                for (let i = 0; i < beginids.length; i++) {
                  let type = indexids.some(function (item) {
                    return item === beginids[i];
                  });
                  if (!type) {
                    jiechukuwei.push(beginids[i]);
                  }
                }

                // 如果最后有而开始没有，说明是新增的
                for (let i = 0; i < indexids.length; i++) {
                  let type = beginids.some(function (item) {
                    return item === indexids[i];
                  });
                  if (!type) {
                    xuanzhongkuwei.push(indexids[i]);
                  }
                }
              }
            }
          }

          let kuqukuwei = {
            'sskqid': xuanzhongkuqu, // 勾选的库区ids
            'sskqidfg': jiechukuqu, // 取消勾选的库区ids
            'kwid': xuanzhongkuwei, // 勾选的库位ids
            'kwidfg': jiechukuwei, // 取消勾选的库位ids
            'sshzid': this.dialogLibrary.row.id, // this.dialogLibrary.row.id
          };

          console.log('要保存的的数据', kuqukuwei);


          if (xuanzhongkuqu.length === 0 && jiechukuqu.length === 0 && xuanzhongkuwei.length === 0 && jiechukuwei.length === 0) {
            return this.$alert('没有更改的内容，您无需保存', '提示');
          } else {
            console.log('进入了保存');
            try {
              await this.post('/wmsOwner/editKw', kuqukuwei);
              this.dialogLibrary.visible = false;
            } catch (err) {
              console.error(err);
            }
          }
          // 有变化的选中的库位的ids
          // let checkids = this.checkSaveids;
        }
      },

      async dialogEditOpen (row) {
        let {contentList} = await this.get('/wmsOwner/getZzgzByHzid/' + row.id);
        row.zzgzIds = contentList;
        await AutoPromise([
          async () => {
            if (!this.DICTIONARY_huozhu) {
              await this.USE('DICTIONARY_huozhu');
            }
          },
          async () => {
            if (this.dialog.wmsShelfRule.length === 0) {
              this.dialog.wmsShelfRule = await this.get('/wmsShelfRule/getDictionary');
            }
          },
          async () => {
            if (this.dialog.wmsTurnOverRule.length === 0) {
              this.dialog.wmsTurnOverRule = await this.get('/wmsTurnOverRule/getDictionary');
            }
          },
        ]);
        for (let i = 1; i <= 4; i++) {
          this['formDialogEdit' + i] = {
            ...this['formDialogEdit' + i],
            ...this.ObjectClone(__formEdit(i), row),
          };
        }
        this.dialogEdit.row = row;
        this.dialogEdit.visible = true;
      },
      dialogEditSave () {
        this.VALIDATE('formDialogEdit4', async option => {
          try {
            let step = {
              ...this.dialogEdit.row,
              ...this.FORMOPTION('formDialogEdit1'),
              ...this.FORMOPTION('formDialogEdit2'),
              ...this.FORMOPTION('formDialogEdit3'),
              ...this.FORMOPTION('formDialogEdit4'),
              ...option,
            };
            delete step.gxsj;
            let ids = '';
            for (let item of step.zzgzIds) {
              ids += item + ',';
            }
            step.zzgzIds = ids.substring(0, ids.length - 1);
            await this.post('/wmsOwner/edit', step);
            this.tableWatch('table');
            this.dialogEditInit();
            this.dialogEdit.visible = false;
          } catch (err) {
            console.log(err);
          }
        });
      },
      dialogEditPre () {
        this.dialogEdit.activeName = parseInt(this.dialogEdit.activeName) - 1 + '';
      },
      dialogEditNext () {
        this.VALIDATE('formDialogEdit' + this.dialogEdit.activeName, option => {
          this.dialogEdit.activeName = parseInt(this.dialogEdit.activeName) + 1 + '';
        });
      },
      dialogLibraryInit () {
        this.dialogLibrary.row = {};
        this.dialogLibrary.tree.data = [];
        this.dialogLibrary.tree.ids = [];
        this.$refs[this.dialogLibrary.tree.ref].setCheckedKeys([]);
      },
      // async dialogLibraryOpen (row) {
      //   let {data, ids} = await this.get('/wmsOwner/selectPostionBySshzidOrFree/' + row.id);
      //   this.dialogLibrary.row = row;
      //   this.dialogLibrary.visible = true;
      //   let _this = this;
      //   this.$nextTick(function () {
      //     _this.dialogLibrary.tree.data = data;
      //     _this.$refs[this.dialogLibrary.tree.ref].setCheckedKeys(ids);
      //   });
      // },
      // async dialogLibrarySave () {
      //   try {
      //     await this.post('/wmsOwner/editLibraryposition', {
      //       ids: this.$refs[this.dialogLibrary.tree.ref].getCheckedKeys(true),
      //       sshzid: this.dialogLibrary.row.id,
      //     });
      //     this.dialogLibrary.visible = false;
      //   } catch (err) {
      //     console.error(err);
      //   }
      // },
      dialogOrderTypeInit () {
        this.dialogOrderType.row = {};
        this.tableOrderType.ids = [];
        this.$refs.tableOrderType.$refs.tableOrderType.clearSelection();
      },
      async dialogOrderTypeOpen (row) {
        this.tableOrderType.url = this.tableOrderType.baseUrl + row.id;
        this.dialogOrderType.row = row;
        this.tableOrderType.ids = await this.get('/wmsOwner/getOrderTypeIds/' + row.id);
        this.tableWatch('tableOrderType');
        this.dialogOrderType.visible = true;
      },
      async dialogOrderTypeSave () {
        await this.post('/wmsOwner/editOrderType', {
          ids: this.tableIds('tableOrderType'),
          sshzid: this.dialogOrderType.row.id,
        });
        this.dialogOrderTypeInit();
        this.dialogOrderType.visible = false;
      },
      dialogStepLibraryInit () {
        this.dialogStepLibrary.row = {};
        this.formDialogStepLibrary = {
          ...this.formDialogStepLibrary,
          ...this.ObjectClone(__formDialogStepLibrary()),
        };
        this.resetFields('formDialogStepLibrary');
      },
      async dialogStepLibraryOpen (row) {
        let {jhqkwMc, djcwMc} = await this.get('/wmsOwner/getAllKw/' + row.id);
        this.formDialogStepLibrary.jhqkwMc = jhqkwMc;
        this.formDialogStepLibrary.djcwMc = djcwMc;
        this.dialogStepLibrary.row = row;
        this.dialogStepLibrary.visible = true;
      },
      dialogStepLibrarySave () {
        this.VALIDATE('formDialogStepLibrary', async option => {
          await this.post('/wmsOwner/addAllKw/' + this.dialogStepLibrary.row.id, option);
          this.dialogStepLibraryInit();
          this.dialogStepLibrary.visible = false;
        });
      },
    },
    mounted: function () {
      this.tableWatch('table');
      console.log(this);
    },
  });
</script>
<style scoped lang="scss">
  .box-card {
    margin: 20px;
  }

  .createTimeSpan {
    display: block;
    margin-top: 34px;
  }

  @media screen and (max-width: 800px) {
    .createTimeSpan {
      margin-top: 0;
    }
    .box-card {
      margin: 0;
    }
  }

  .el-select {
    width: 100%;
  }
</style>

<style lang="scss">
  .el_tree{
    min-width: 10rem;
    max-height: 28rem;
    overflow: auto;
  }
</style>
